              #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <string.h>
#include <ctype.h>

#define WL_MAX_NUM_SSID  4
#define WL_SIZE_2_MAX    2  
#define WL_SIZE_4_MAX    4  
#define WL_SIZE_8_MAX    8  
#define WL_SIZE_132_MAX  132
#define WL_SM_SIZE_MAX   16
#define WL_MID_SIZE_MAX  32
#define WL_SSID_SIZE_MAX 48
#define WL_MIN_PSK_LEN	8
#define WL_MAX_PSK_LEN	64
#define WL_WPA_PSK_SIZE_MAX  72  // max 64 hex or 63 char
#define WL_RADIUS_KEY_SIZE_MAX  88 // max is 80, limited by nas_wksp.h.  IAS allow up to 128 char
#define WL_LG_SIZE_MAX   1024
#define WL_KEY_NUM       4
#define WL_WDS_NUM       4
#define WL_MIN_FRAGMENTATION_THRESHOLD  256
#define WL_MAX_FRAGMENTATION_THRESHOLD  2346
#define WL_MIN_RTS_THRESHOLD            0
#define WL_MAX_RTS_THRESHOLD            2347
#define WL_MIN_DTIM                     1
#define WL_MAX_DTIM                     255
#define WL_MIN_BEACON_INTERVAL          1
#define WL_MAX_BEACON_INTERVAL          65535
#define WL_KEY64_SIZE_HEX               10
#define WL_KEY64_SIZE_CHAR              5
#define WL_KEY128_SIZE_HEX              26
#define WL_KEY128_SIZE_CHAR             13
#define WL_MAX_ASSOC_STA                128

typedef struct {
	int wlSsidIdx;
	char wlMode[WL_SM_SIZE_MAX];
	char wlCountry[WL_SM_SIZE_MAX];
	char wlFltMacMode[WL_SM_SIZE_MAX];
	char wlPhyType[WL_SIZE_2_MAX];
	char wlBasicRate[WL_SIZE_8_MAX];
	char wlProtection[WL_SIZE_8_MAX];
	char wlPreambleType[WL_SM_SIZE_MAX];
	char wlAfterBurnerEn[WL_SIZE_8_MAX];
	char wlFrameBurst[WL_SIZE_4_MAX];
	char wlWlanIfName[WL_SIZE_4_MAX];
	char wlWds[WL_WDS_NUM][WL_MID_SIZE_MAX];
	int  wlCoreRev;
	int  wlEnbl;
	int  wlChannel;
	int  AutoChannelEnable;  //wyj add
	int  WpsEnable;         //wyj
	int  wlFrgThrshld;
	int  wlRtsThrshld;
	int  wlDtmIntvl;
	int  wlBcnIntvl;
	long wlRate;
	int  wlgMode;
	int  wlLazyWds;
	int  wlBand;
	int  wlMCastRate;
	int bakWlMCastRate;
	int  ezc_version;
	int  ezc_enable;
	int  wlInfra;
	int  wlAntDiv;
	int	wlWme;
	int  wlWmeNoAck;
	int  wlWmeApsd;
	int  wlTxPwrPcnt;
	int  wlRegMode;
	int  wlDfsPreIsm;
	int  wlDfsPostIsm; 
	int  wlTpcDb;       
	int  wlCsScanTimer;  
	int  wlGlobalMaxAssoc;
#ifdef SUPPORT_SES   
	int	wlSesEnable;
	int  wlSesEvent;
	char wlSesStates[WL_SIZE_8_MAX];
	char wlSesSsid[WL_SSID_SIZE_MAX];
	char wlSesWpaPsk[WL_WPA_PSK_SIZE_MAX];  
	int  wlSesHide;
	int  wlSesAuth; 
	char wlSesAuthMode[WL_SIZE_8_MAX]; 
	char wlSesWep[WL_SM_SIZE_MAX];   
	char wlSesWpa[WL_SM_SIZE_MAX];      
	int  wlSesWdsMode;      
	int	wlSesClEnable;   
	int  wlSesClEvent;   
	char wlWdsWsec[WL_SIZE_132_MAX];   
#endif   
#if 1//def SUPPORT_MIMO
	int wlNBw; /* runtime */
	int wlNBwCap;
	int wlNCtrlsb;
	int wlNBand;
	int wlNMcsidx;
	char wlNProtection[WL_SIZE_8_MAX];
	char wlRifs[WL_SIZE_8_MAX];
	char wlAmpdu[WL_SIZE_8_MAX];
	char wlAmsdu[WL_SIZE_8_MAX];
	char wlNmode[WL_SIZE_8_MAX];
	int wlNReqd;
#endif      
}WIRELESS_VAR;

void test(char *str, unsigned char index, char *subStr)
{
	char *s = NULL, *p = NULL;
	char *delim=";";
	unsigned int count=0;
	
	if(str == NULL || subStr == NULL)
		return ;
	
	s = str;
	p = strtok(s,delim);
	if (index == 0)
	{
		strcpy(subStr, p);
		return ;
	}
	
	while((p=strtok(NULL,delim)))
	{
		count++;
		if(index == count && p)
		{
			strcpy(subStr, p);
			return ;
		}
	}
}

char *test2(char *str, unsigned char index, char *subStr)
{
	char *p = NULL;
	int idx = 0;
	
	p = strtok(str, ";");
	
	for (idx=0;idx<index;idx++)
		p = strtok(NULL, ";");
	
	if (p!=NULL)
		strcpy(subStr, p);
	
	return p;
}

int ifx_if_str_hex(const char *str)
{
	int i = 0, len = 0;
	
	if (str == NULL)
		return 0;
	
	len = strlen(str);
	
	for (i = 0; i < len; i++)
	{
		if (!isxdigit(str[i]))
			return 0;
	}
	
	return 1;
}

int ifx_if_str_ascii(const char *str)
{
	int i = 0, len = 0;
	
	if (str == NULL)
		return 0;
	
	len = strlen(str);
	
	for (i = 0; i < len; i++)
	{
		if (!isascii(str[i]))
			return 0;
	}
	
	return 1;
}

void strChange(char *value)
{
	strcpy(value,"hzftestgood");
}

struct st{
	int c;
	short int b;
	char a;
};

#define RS 5
main()
{
#if 0
	int i = 0;
	int map = 65535;
	char buf[100] = "test";
	
	for (i=0; i<8; i++)
	{
		if (!((map>>i) & 1))
		{
			break;
		}
	}
	printf("i=%d\n",i);
	printf("sizeof(WIRELESS_VAR)=%d\n",sizeof(WIRELESS_VAR));
	
	strChange(buf);
	printf("\nbuf=%s\n",buf);
	
	printf("\nstrchr=%s\n",strchr(buf, 's'));
#endif
#if 0
	char *hostname = NULL, *separator = "&";
	char lst[] = {"10.28.102.7&17.18.102.2&10.28.100.2&192.168.1.100&"};
	
	for( hostname = strtok( lst, separator ); hostname != NULL; hostname = strtok( NULL, separator ) ) {
		printf("host=%s;\n",hostname);
	}
#endif

#if 0
	printf("space key value=%2x; %c; tab=%2x;abc%cdef\n", ' ', 0x20, '\t',0x09);
	printf("space key value=%2x; %c; tab=%2x;abc\tdef\n", ' ', 0x20, '\t');
#endif

#if 0
	int idx = 0, portid = 0, vpi = 0, vci = 0;
	char servicetype[16];
	char *strToken = "1_OTHER_B_0_8_88";
	char wantype;

	sscanf(strToken+10, "%d_%d_%d", &portid, &vpi, &vci);
printf("###hzf test4x id=%d;vpi=%d;vci=%d###\n",portid,vpi,vci);
#endif

#if 0
	int a[5] = {1,2,3,4,5};
	int *p = (int *)(&a+1);

	printf("###hzf test %d;%d###\n", *(a+1), *(p-1));
#endif

#if 0
	union{
		int a;
		char b;
	}un;

	un.a=1;

	union{
		int a;
		char b[2];
	}u;

	u.a=0;
	u.b[0]=10;
	u.b[1]=1;

	printf("###hzf test %x;%d;###\n", u.a, un.b);
	printf("###hzf test sizeof(st)=%d;###\n", sizeof(struct st));
#endif

#if 0
	char *p1;
	long *p2;
	
	p1=(char *)0x80000000;
	p2=(long *)0x8A000000;
	
	printf("0x%x;0x%x", p1+1, p2+5);
#endif

#if 0
	unsigned long l = 0x12345678UL;
	printf("###hzf test %x;###\n", l);

	char *p = (char *)malloc(0);
	if(NULL == p)
		printf("###hzf test malloc fail;###\n");
	else
		printf("###hzf test malloc ok;###\n");
#endif

#if 0
	char *p1 = "name";
	char *p2 = NULL;

	p2 = (char *)malloc(20);
	memset(p2,0,20);
	
	while(*p2++ = *p1++);

	printf("###hzf test p2=%s;###\n", p2);
#endif

#if 0
	unsigned short a = 10;
	char c = 128;

	printf("###hzf test ~a=%x;c=%d;sizof(unsigned short)=%d###\n", ~a, c, sizeof(unsigned short));
#endif

#if 0
	struct s{
		int b1:5;
		int b2:2;
	};

	struct s s1;
	char str1[100];
	strcpy(str1, "01234567890abcdefghijk");
	memcpy(&s1, str1, sizeof(s1));

	printf("###hzf test b1=%d;b2=%d###\n", s1.b1, s1.b2);
#endif

	int i = 1;

	switch(i)
	{
	case 0:
		printf("###hzf test 0 ###\n");
	case 1:
		printf("###hzf test 1 ###\n");
	case 2:
		printf("###hzf test 2 ###\n");
	default:
		printf("###hzf test default ###\n");
	}

	return 0;
}

